package fhq.hcmute.modernshopping.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import fhq.hcmute.modernshopping.R;
import fhq.hcmute.modernshopping.adapter.ShoppingPagerAdapter;

/**
 * @author: Hien Nguyen Le
 * @emai: hien.nguyenle.it@gmail.com
 * 
 */
public class ShoppingActivity extends FragmentActivity {
	private ViewPager mViewPager;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_shopping);

		mViewPager = (ViewPager) findViewById(R.id.view_pager);

		mViewPager.setAdapter(new ShoppingPagerAdapter(
				getSupportFragmentManager(), getApplicationContext()));
	}

	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		if (item.getItemId() == R.id.menu_item_scan_qrcode) {
			Intent intent = new Intent(getApplicationContext(),
					ScanQrCodeActivity.class);
			intent.putExtra(ScanQrCodeActivity.SCAN_QRCODE_KEY,
					R.layout.activity_shopping);
			startActivity(intent);
		}
		return super.onMenuItemSelected(featureId, item);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.shopping_menu, menu);
		return true;
	}
}
